<?php
abstract class LogParser {
	private $logReader = null;
	public function __construct($log_reader) {
		if ($log_reader instanceof LogReader) {
			$this->logReader = $log_reader;
		}
	}
	public function parse(){
		$log_str = $this->logReader->read();
//		var_dump($log_str);
		if($log_str !== false){
			if ($parsed = $this->parser($log_str)) {
				return $parsed;
			}
			else {
				$this->onError('parse_error', $log_str);
				return array('error' => true,
				'error_str' => $log_str);
			}
		}
		return false;
	}
	public function reset(){
		$this->logReader->reset();
	}
	
	private function onError($error_name, $note) {
		$log_name=$this->getName();
		error($error_name, $note, $log_name);
		
	}
	
	public abstract function getName();
	protected abstract function parser($log); 
	public abstract function getDBVersion($log); 
}
?>